import os


# print(os.listdir('../python06_pyspark'))
# print(os.path.isdir('../'))
# print(os.path.exists('../'))

def recursion_dir(path):
    """
    递归打印文件夹下的文件
    :param path:
    :return:
    """
    file_list = list()
    if os.path.exists(path):
        for i in os.listdir(path):
            new_path = path + '/' + i
            if os.path.isdir(new_path):
                file_list += recursion_dir(new_path)
            else:
                file_list.append(new_path)
    else:
        print(f"目录不存在：{path}")
        return []
    return file_list


if __name__ == '__main__':
    # result_list = recursion_dir('../python06_pyspark')
    # r原始字符
    # result_list = recursion_dir(r'E:\Code\06-Python\python_study\python06_pyspark')
    # 转义字符
    # result_list = recursion_dir('E:\\Code\\06-Python\\python_study\\python07_extend')
    # / 写法
    # result_list = recursion_dir('E:/Code/06-Python/python_study/python07_extend')
    result_list = recursion_dir('.')
    print(result_list)
